home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / miscnix.zip / STRRNCHR.A < prev    next >
Text File  |  1988-05-20  |  517b  |  30 lines

  1. ;STRRNCHR - Search for matching character.
  2. ;    char *strrnchr(addr: address; len: integer; pat: char);
  3.  
  4. ;    This is like strrchr (=rindex) except that it works with fixed length
  5. ;    strings.
  6.  
  7.     cseg
  8.     public    strrnchr_
  9.  
  10. strrnchr_:pop    bx
  11.     pop    di        ;start address
  12.     pop    cx        ;length
  13.     pop    ax        ;character to match
  14.     push    ax
  15.     push    cx
  16.     push    di
  17.     push    bx
  18.  
  19.     std
  20.     push    ds
  21.     pop    es
  22.     add    di,cx
  23.     dec    di        ;sets nonzero status
  24.     repne    scasb
  25.     jne    s1        ;if not found
  26.     inc    di        ;if found, back up
  27. s1:    xchg    ax,di
  28.     ret
  29.     end
  30.